<%--
  Created by IntelliJ IDEA.
  User: 90509
  Date: 2020/9/1
  Time: 18:12
  To change this template use File | Settings | File Templates.
--%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <base href="<%=basePath%>"/>
    <title>课程安排</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/pintuer.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/admin.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" />
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
    <style>
        .divvv{
            height: 80px;
            width: 50%;
            border-radius: 80px;
            line-height: 80px;
            color: #FFFFFF;
            font-size: 16px;
        }
        .queren{
            font-size: 16px;
            width: 200px;
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
<div class="panel panel-primary" style="border: 1px solid dodgerblue;" align="center">
    <div class="panel-heading" style="background-color: dodgerblue; color: #F9F9F9;font-size: 20px">
        课程安排
    </div>
    <div style="background-color: lightskyblue;" class="divvv">
        <span style="margin-left:36px">请选择班级：</span>
        <select style="-webkit-text-fill-color: slategrey;width: 200px;display: inline-block" id="classID" class="form-control">
        </select>
        <button id="goone" onclick="goone()" class="btn btn-success btn-sm">确定</button>
    </div>
    <div style="background-color: #b7d2ff;" class="divvv">
        可选课程：
        <select style="-webkit-text-fill-color: slategrey;width: 200px;display: inline-block" id="courceID" class="form-control">
        </select>
    </div>
    <div style="background-color: #03b6fd;" class="divvv">
        分配老师：
        <select style="-webkit-text-fill-color: slategrey;width: 200px;display: inline-block" id="teacherID" class="form-control">
        </select>
    </div>

    <div style="background-color: dodgerblue;" class="divvv">
        分配教室：
        <select style="-webkit-text-fill-color: slategrey;width: 200px;display: inline-block" id="roomID" class="form-control">
        </select>
    </div>

    <div style="background-color: mediumslateblue;" class="divvv">
        选择时间：
        <input type="date" id="ddate" class="form-control"style="width: 200px;display: inline-block">
    </div>
    <br>
    <button onclick="inserTable()" class="btn btn-success btn-sm queren" >确认并安排课程</button>
</div>
</body>
</html>
<script>
    $(function(){
        claList();
        teacherList();
        roomList();
    })
    function claList(){
        $.ajax({
            url:"${pageContext.request.contextPath}/teach/selectClass",
            type:"get",
            dataType:"json",
            success:function(data){
                var claList = data.data;
                var html="";
                for (var i = 0;i<claList.length;i++){
                    html+="<option style='color: #1b6d85' value="+claList[i].clId+">"+claList[i].clName+"</option>"
                }
                $("#classID").html(html);
            }
        })
    };
    function goone() {
        courList();
    };

    function courList(){
        var clId = $("#classID").val();
        $.ajax({
            url:"${pageContext.request.contextPath}/teach/courList",
            type:"get",
            data:{"clId":clId},
            dataType:"json",
            success:function(data){
                var courList = data.data;
                var html="";
                for (var i = 0;i<courList.length;i++){
                    html+="<option style='color: #1b6d85' value="+courList[i].cId+">"+courList[i].cName+"</option>"
                }
                $("#courceID").html(html);
            }
        })
    }
    function teacherList(){
        var clId = $("#classID").val();
        $.ajax({
            url:"${pageContext.request.contextPath}/teach/teacherList",
            type:"get",
            dataType:"json",
            success:function(data){
                var userList = data.data;
                var html="";
                for (var i = 0;i<userList.length;i++){
                    html+="<option style='color: #1b6d85' value="+userList[i].uId+">"+userList[i].name+"</option>"
                }
                $("#teacherID").html(html);
            }
        })
    }
    function roomList(){
        var clId = $("#roomID").val();
        $.ajax({
            url:"${pageContext.request.contextPath}/teach/roomList",
            type:"get",
            dataType:"json",
            success:function(data){
                var userList = data.data;
                var html="";
                for (var i = 0;i<userList.length;i++){
                    html+="<option style='color: #1b6d85' value="+userList[i].rId+">"+userList[i].rName+"</option>"
                }
                $("#roomID").html(html);
            }
        })
    }
    function inserTable() {
        var clId = $("#classID").val();
        var cId = $("#courceID").val();
        var uId = $("#teacherID").val();
        var skRoom = $("#roomID").val();
        var skTime = $("#ddate").val();
        $.ajax({
            url:"${pageContext.request.contextPath}/teach/add",
            data:{"clId":clId,"cId":cId,"uId":uId,"skRoom":skRoom,"skTime":skTime},
            type:"get",
            dataType:"json",
            success:function(data){
                var info = data.info;
                alert(info);
            }
        })
    }
</script>
